Add 'maxcount' argument to radius filter to allow user to limit number of
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 6 May 2005 17:45:30 +0000 (17:45 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 6 May 2005 17:45:30 +0000 (17:45 +0000)
points to be passed downstream.  (Specifically to stop Magellan's Geocache
Manager from hurting itself.)

gpsbabel/position.c

index 49a79929b76cf8a726e059a9d0ca4e2093493973..2df410826ae3e885cf97292a01ee331af6c94108 100644 (file)
@@ -35,6 +35,8 @@ static char *latopt = NULL;
 static char *lonopt = NULL;
 static char *exclopt = NULL;
 static char *nosort = NULL;
+static char *maxctarg = NULL;
+static int maxct;
 
 waypoint * home_pos;
 
@@ -64,6 +66,8 @@ arglist_t radius_args[] = {
                NULL, ARGTYPE_BOOL },
        {"nosort", &nosort,    "Inhibit sort by distance to center.",
                NULL, ARGTYPE_BOOL },
+       {"maxcount", &maxctarg,"Output no more than this number of points",
+               NULL, ARGTYPE_INT },
        {0, 0, 0, 0, 0}
 };
 
@@ -325,9 +329,14 @@ radius_process(void)
         */
        for (i = 0; i < wc; i++) {
                waypoint * wp = comp[i];
-               waypt_add(wp);
+
                xfree(wp->extra_data);
                wp->extra_data = NULL;
+
+               if (maxctarg && i >= maxct) {
+                       continue;
+               }
+               waypt_add(wp);
        }
 
        xfree(comp);
@@ -348,6 +357,12 @@ radius_init(const char *args) {
                }
        }
 
+       if (maxctarg) {
+               maxct = atoi(maxctarg);
+       } else {
+               maxct = 0;
+       }
+
        home_pos = (waypoint *) xcalloc(sizeof(*home_pos), 1);
 
        if (latopt)